import 'package:flutter/material.dart';

class ListViewHomePage extends StatefulWidget {
  @override
  _ListViewHomePageState createState() => _ListViewHomePageState();
}

class _ListViewHomePageState extends State<ListViewHomePage> {
  bool select = false;
  List list = [];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    for (int i = 0; i < 100; i++) {
      list.add("list $i");
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("listview配置"),
      ),
      // 线性布局
      body: ListView.builder(
        itemBuilder: (BuildContext context, num index) {
          return Container(
              width: 80,
              height: 80,
              child: Text(list[index]),
              margin: EdgeInsets.all(10),
              color: Colors.grey);
        },
        itemCount: list.length,
      ),
    );
  }
}
